package com.base.po.param;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
//import org.codehaus.jackson.JsonGenerationException;
//import org.codehaus.jackson.map.JsonMappingException;
//import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;

/**
 * 网络状态
 *
 * @author God
 */
@ApiModel(value = "标准接口返回数据模型")
public class NetState {

    public static final int SUCCESS_CONN = 2000;// 操作查询成功
    public static final int NODATA = 9001; // 查询成功无记录
    public static final int FEAILED = 9002; // 查询失败
    public static final int ACCOUNT_ERROR = 1000; // 账户不存在或被禁用
    public static final int API_NOT_EXISTS = 1001;// 请求的接口不存在
    public static final int API_NOT_PER = 1002;// 没有该接口的访问权限
    public static final int PARAMS_ERROR = 1004;// 参数为空或格式错误
    public static final int SIGN_ERROR = 1005;// 数据签名错误
    public static final int AMOUNT_NOT_QUERY = 1010;// 余额不够，或者过期
    public static final int API_DISABLE = 1011;// 查询权限已被限制
    public static final int DATA_RE = 1012; // 数据重复
    public static final int UNKNOWN_IP = 1099;// 非法IP请求
    public static final int SYSTEM_ERROR = 9999;// 系统异常
    public static final int LOGIN_REGISTERED = 2001;// 已注册发送验证码
    public static final int LOGIN_UNREGISTERED = 2002;// 未注册发送验证码
    public static final int SUCCESS_OPERATE = 3000;// 操作成功
    public static final int ERROR_OPERATE = 3001; //操作失败
    public static final int WX_OPENID_REPEAT = 4001; // 微信重复绑定
    public static final int WX_OPENID_UNBOUND = 4002; // 微信未绑定
    public static final int APPLE_USERID_REPEAT = 4003; // 苹果重复绑定
    public static final int ZFB_NOT_BOUND = 5001; // 支付宝未实名绑定
    public static final int NEED_SYSTEM_PARAM = 100; // 缺少系统性参数
    public static final int PARAM_VERIFY_FILURE = 500; // 参数验证失败
    public static final int TIME_OUT_VERIFY = 300; // 超时
    @ApiModelProperty(value="网络状态",name="data")
    private String data;
    @ApiModelProperty(value="网络状态码,返回2000成功",name="errorCode")
    private int errorCode;
    @ApiModelProperty(value="数据Model",name="Json")
    private Object Json;

    public Object getJson() {
        return Json;
    }

    public void setJson(Object json) {
        Json = json;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    private Object otherJson;// 不改变原接口前提下 添加新数据

    public Object getOtherJson() {
        return otherJson;
    }

    public void setOtherJson(Object otherJson) {
        this.otherJson = otherJson;
    }

    public NetState() {
    }

    public NetState(String data, int errorCode, Object json) {
        this.data = data;
        this.errorCode = errorCode;
        Json = json;
    }

    public NetState(int errorCode, String data, Object json) {
        this.data = data;
        this.errorCode = errorCode;
        Json = json;
    }

    public NetState(int errorCode, String data) {
        this.data = data;
        this.errorCode = errorCode;
    }

    /**
     * @Date: 2019/11/7 14:05
     * @Description: 有时传递JSON会报500，但是无错误信息，此方法可以找出错误原因
     */
    public static String NetStateFindError(NetState netState) {
//        ObjectMapper mapper = new ObjectMapper();
//        String jsonString = null;
//        try {
//            jsonString = mapper.writeValueAsString(netState);
//            System.out.print(jsonString);
//        } catch (JsonGenerationException e) {
//            e.printStackTrace();
//        } catch (JsonMappingException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        return "";
    }
}
